package com.atguigu.webdemo.order.controller;

import com.alibaba.fastjson.JSON;
import com.atguigu.webdemo.order.bean.OrderInfo;
import com.atguigu.webdemo.order.service.OrderInfoService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 订单表 前端控制器
 * </p>
 *
 * @author liuxu
 * @since 2023-10-08
 */
@RestController
@RequestMapping("/order")
public class OrderInfoController {

    @Autowired
    OrderInfoService orderInfoService;

    //查询
    @GetMapping("/select1")
    public OrderInfo select(@RequestParam("id") Long id){
        return orderInfoService.getById(id);
    }

    @GetMapping("/select2")
    public String select(@RequestParam(value = "name") String name){
        List<OrderInfo> consignee = orderInfoService.list(
                new QueryWrapper<OrderInfo>().like("consignee", name)
        );
        return JSON.toJSONString(consignee);
    }


}
